package com.itetchologyandenglish.home.controller.Page;

import com.itetchologyandenglish.home.enetity.Auth;
import com.itetchologyandenglish.home.enetity.Result;
import com.itetchologyandenglish.home.enetity.Roles;
import com.itetchologyandenglish.home.service.AdminService;
import com.itetchologyandenglish.home.service.AuthService;
import com.itetchologyandenglish.home.service.RoleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/admin")
@Controller
public class AdminPageController {
    @Resource
    RoleService roleService;
    @Resource
    AdminService adminService;
    @Resource
    AuthService authService;
    @RequestMapping("/system")
    public ModelAndView system(ModelAndView model){
//        adminService.getList().stream().forEach(System.out::println);
//        model.getModel().put("list",adminService.getList());
//        model.setViewName("system");
        return new ModelAndView("system");
    }
    @RequestMapping("/adminedit")
    public ModelAndView adminedit(Integer id){
        ModelAndView modelAndView=new ModelAndView();
        List<Roles> list=roleService.getRoleList();
        modelAndView.getModel().put("list",list);
        modelAndView.getModel().put("id",id);
        modelAndView.setViewName("adminedit");
        return modelAndView;
    }
    @RequestMapping(value="/authedit")
    public ModelAndView authedit(Integer id,ModelAndView modelAndView){
        modelAndView.setViewName("authedit");
        modelAndView.getModel().put("id",id);
        return modelAndView;
    }
    @RequestMapping("/admin")
    public ModelAndView addAdmin(ModelAndView modelAndView){
        List<Roles> list=roleService.getRoleList();
        modelAndView.getModel().put("list",list);
        modelAndView.setViewName("admin");
        return modelAndView;
    }
    @RequestMapping("/role")
    public ModelAndView role(ModelAndView model){
        return new ModelAndView("role");
    }
    @RequestMapping("/auth")
    public ModelAndView auth(ModelAndView model){
        return new ModelAndView("auth");
    }
    @RequestMapping("/addrole")
    public ModelAndView addrrole(ModelAndView model){
        return new ModelAndView("addRole");
    }
    @RequestMapping("/addAuth")
    public ModelAndView addAuth(ModelAndView model){
        model.setViewName("addAuth");
        return model;
    }


}
